window.onload=function(){
    let bun=document.querySelector("button")
    let bun_post=document.querySelector("#bun_post")
    // bun.addEventListener("click",()=>{
    //     let username = document.getElementById("username").value
    //     let password = document.getElementById("password").value
    //     fetch("http://172.19.1.251:8080/login",{
    //        method:"GET",
    //        headers:{
    //         "Content-Type":"application/x-www-form-urlencoded"
    //     }
    //     }).then((res)=>{
    //         console.log("success")
    //         return res.text()
    //     }).then((res)=>{
    //         console.log(res)
    //     }).catch(()=>{
    //         console.log("fail")
    //     })
    // })
    // bun_post.addEventListener("click",()=>{
    //     let username = document.getElementById("username").value
    //     let password = document.getElementById("password").value
    //     data={
    //         username:"username",
    //         password:"password"
    //     }
    //     fetch("http://172.19.1.251:8080/login",{
    //         method:"POST",
    //         headers:{
    //             "Content-Type":"application/json"
    //         },
    //         body:JSON.stringify(data)
    //     }).then((res)=>{
    //         console.log("success")
    //         return res.text()
    //     }).then((res)=>{
    //         console.log(res)
    //     }).catch(()=>{
    //         console.log("fail")
    //     })
    // })
    bun.addEventListener("click",()=>{
        let username = document.getElementById("username").value
        let password = document.getElementById("password").value
        axios.get("http://172.19.1.251:8080/login",{
            params:{
                username:username,
                password:password
            }
        }).then((res)=>{
            console.log(res.data)
        })
    })
    bun_post.addEventListener("click",()=>{
        let username = document.getElementById("username").value
        let password = document.getElementById("password").value
        axios.post("http://172.19.1.251:8080/login",{
            username:username,
            password:password
        }).then((res)=>{
            console.log(res.data)
        })
    })
}